<?php 
class Provider extends Module{
    static function permission(){
        return array(
                    'provider_admin' => "Quản trị Nhà cung cấp",
                );
    }
    
	function Provider($row){
		Module::Module($row);
		if(User::have_permit('provider_admin')){
			switch(Url::get('cmd')){
                case 'delete':
                    $id = Url::getInt('id', 0);
                    if($id){
                        $provider=DB::select('provider','id='.$id);
                        if($provider){
                            Db_Provider::delProviderById($id);
                        }
                    }
                    Url::redirect_current();
                    break;
                case 'edit':
                case 'add':
                    require_once 'forms/EditProvider.php';
                    $this->add_form(new EditProviderForm());
                    break;
                default:
                    require_once 'forms/ListProvider.php';
                    $this->add_form(new ListProviderForm());
                    break;
            }
		}
		else{
			Url::access_denied();
		}
	}
}
?>